package db;



public class DbSelect implements DbSelectInterface {

	private String from = null;
	private String where = null;
	private String columns = null;

	public DbSelect() {

	}

	public DbSelect(String from) {
		this.from = from;
	}

	@Override
	public DbSelectInterface from(String from) {
		this.from = from;
		return this;
	}

	@Override
	public DbSelectInterface where(String where) {
		this.where = where;
		return this;
	}

	@Override
	public DbSelectInterface columns(String columns) {
		this.columns = columns;
		return this;
	}

	@Override
	public String toString() {
		String sql = "SELECT";
		if (columns == null) {
			sql += " *";
		} else {
			sql += " " + columns;
		}
		if (from == null) {
			return null;
		} else {
			sql += " FROM " + from;
		}

		if (where != null) {
			sql += " WHERE " + where;
		}
		return sql;
	}

}